<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8">
    <title>综合数据监控平台</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">
    
    <!-- Le styles -->
    <script type="text/javascript" src="assets/js/jquery.min.js"></script>

    <link rel="stylesheet" href="assets/css/style.css">
    <link rel="stylesheet" href="assets/css/loader-style.css">
    <link rel="stylesheet" href="assets/css/bootstrap.css">
    <link rel="stylesheet" href="assets/css/signin.css">
    <link rel="stylesheet" href="assets/css/extra-pages.css">


    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
        <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
        <![endif]-->
    <!-- Fav and touch icons -->
    <link rel="shortcut icon" href="assets/ico/favicon.ico">
    <style type="text/css">
        /*body {
            overflow:hidden!important;
            padding-top: 120px;
        }*/
        div.lockscreen-name {
            margin: 20px auto;
        }
    </style>
</head>

<body id="lock">
    <!-- Preloader -->
    <div id="preloader">
        <div id="status">&nbsp;</div>
    </div>




    <!-- Main content -->
    <section class="page-error">

        <div class="headline-lock text-center" id="time">
            <span></span>
            <!-- Time auto generated by js -->
        </div>
        <!-- /.headline -->
        <div class="lockscreen-name">田七</div>
        <div class="lockscreen-image">
            <img src="assets/img/user.jpg" alt="用户头像">
        </div>
        <!-- User name -->


        <!-- START LOCK SCREEN ITEM -->
        <div class="lockscreen-item">


            <!-- lockscreen credentials (contains the form) -->
            <div class="lockscreen-credentials">

                <div class="input-group">
                    <input type="password" class="form-control" placeholder="请输入密码..." id="checkPass">
                    <div class="input-group-btn">
                        <button class="btn btn-flat" onclick="userCheck()"><i class="fa fa-arrow-right text-muted"></i>
                        </button>
                        
                    </div>
                </div>

            </div>
            <!-- /.lockscreen credentials -->

        </div>
        <!-- /.lockscreen-item -->

        <div class="lockscreen-link">
            <a class="lock-link" href="login.html?b=1">或使用其他账号登录</a>
        </div>

        <div class="alert" style="display: none;">
            <!-- <button type="button" class="close" data-dismiss="alert">&times;</button> -->
            <span id="alert"></span>
        </div>
    </section>



    <!--  END OF PAPER WRAP -->




    <script type="text/javascript" src="assets/js/load.js"></script>
    <script type="text/javascript" src="assets/js/main.js"></script>
    <script type="text/javascript">
        $(function() {
            startTime();
            $(".center").center();
            $(window).resize(function() {
                $(".center").center();
            });
        });

        /*  */

        function startTime() {
            var today = new Date();
            var h = today.getHours();
            var m = today.getMinutes();
            var s = today.getSeconds();

            // add a zero in front of numbers<10
            m = checkTime(m);
            s = checkTime(s);

            //Check for PM and AM
            var day_or_night = (h > 11) ? "PM" : "AM";

            //Convert to 12 hours system
            if (h > 12)
                h -= 12;

            //Add time to the headline and update every 500 milliseconds
            $('#time').html(h + ":" + m + ":" + s + " " + day_or_night);
            setTimeout(function() {
                startTime()
            }, 500);
        }

        function checkTime(i) {
            if (i < 10) {
                i = "0" + i;
            }
            return i;
        }

        /* CENTER ELEMENTS IN THE SCREEN */
        jQuery.fn.center = function() {
            this.css("position", "absolute");
            this.css("top", Math.max(0, (($(window).height() - $(this).outerHeight()) / 2) +
                $(window).scrollTop()) - 30 + "px");
            this.css("left", Math.max(0, (($(window).width() - $(this).outerWidth()) / 2) +
                $(window).scrollLeft()) + "px");
            return this;
        }

        //密码框 的回车事件
        $("#checkPass").keydown(function(event){
            if(event.keyCode == 13) {
                userCheck();
            }
        })
        //密码验证
        function  userCheck() {
            var account = localStorage["RKname"];//当前账号
            var password = $("#checkPass").val();//密码

            if (password == '') {
                $(".alert").addClass("alert alert-warning").show();
                $("#alert").html("请输入密码!");
                // console.log("请输入密码！");
            } else{
                $.ajax({
                    type: 'post',
                    url: "http://139.196.28.69:3000/userlogin",
                    data: { id: account, pass: password },
                    dataType: 'json',
                    success: function (data) {
                        console.log(data);
                        if (data.ret == 1) {
                            jump('/index.html');
                        } else{
                            // alert(data.msg);//错误信息
                            $(".alert").addClass("alert alert-warning").show();
                            $("#alert").html("密码错误!");
                        }

                    }, error: function (XMLResponse) {
                        console.log(XMLResponse);
                    }
                });
            };
        };

        function jump(page) {
            window.location.href = page;
            coursor: pointer;
        }
    </script>


</body>

</html>
